package com.example.iconmaker;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.Bitmap;
import android.graphics.RectF;
import android.opengl.GLUtils;

public class Icon {

	public static float DEFUALT_SIZE = 3.5f;
	private Bitmap mBitmap;
	private Rect2D rect;
	private int mTexture;
	private FloatBuffer texCoordBuffer;
	
	public Icon(float left, float top, float right, float bottom, int texture) {
		rect = new Rect2D(left, top, right, bottom);
		mTexture = texture;
		float[] texVertices = {
			0.0f, 1.0f,
			0.0f, 0.0f,
			1.0f, 0.0f,
			1.0f, 1.0f
		};
		ByteBuffer tbb = ByteBuffer.allocateDirect(texVertices.length * 4);
		tbb.order(ByteOrder.nativeOrder());
		texCoordBuffer = tbb.asFloatBuffer();
		texCoordBuffer.put(texVertices);
		texCoordBuffer.position(0);
		
	}
	
	public void draw(GL10 gl){
		
		gl.glBindTexture(GL10.GL_TEXTURE_2D, mTexture);
 		gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texCoordBuffer);
		rect.draw(gl);
	}
}
